/* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements.  See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License.  You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/


/*************************************************************************
 *\author: starlove
 *************************************************************************/
#ifndef __CC_PYTHON_IMPORT_O_OUTOUT_IMPL__
#define __CC_PYTHON_IMPORT_O_OUTOUT_IMPL__

#include "python_object_output.h"
#include "python_object_nodeobjects.h"

NS_CCPY_BEGIN
	
	PYCLASS_INIT_F(CPyOutput, "Output", "Python Output Object");

	PYCLASS_BEGIN_METHOD_DEF(CPyOutput)
	PYCLASS_ADD_METHOD(CPyOutput,write)
	PYCLASS_END_METHOD_DEF(CPyOutput)

	PYCLASS_BEGIN_GETSET_DEF(CPyOutput)
	PYCLASS_END_GETSET_DEF(CPyOutput)

	PYCLASS_IMP_INTERFACE(CPyOutput)

	PYCLASS_METHOD_IMPL(CPyOutput, write)
	{
		char*        szBuf = 0;
		Py_ssize_t   len = 0;
		if( !PyArg_ParseTuple(pyArgs,"s#",&szBuf,&len) )
		{
			Py_RETURN_NONE;
		}

		if( !szBuf )
			Py_RETURN_NONE;

		if( len == 0 )
			Py_RETURN_NONE;
		if( len == 1 && szBuf[0] == '\n' )
			Py_RETURN_NONE;

		cocos2d::CCLog("%s >>> %s", pySelf->getFlagStr(), szBuf);
		Py_RETURN_NONE;
	}

NS_CCPY_END

#endif